﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class BaseContent : MonoBehaviour
{
    public TileObject rootTile;
    
    private bool isCollider = false;

    public bool CanArrive()
    {
        return !isCollider;
    }

    public virtual void OnInteract(PlayerPawn interactor)
    {

    }

    protected void OnDisable()
    {
#if UNITY_EDITOR
        if (rootTile && rootTile.content == this)
        {
            rootTile.content = null;
        }
#endif
    }

    protected void OnEnable()
    {
#if UNITY_EDITOR
        if (!rootTile)
        {
            rootTile = GetComponentInParent<TileObject>();
        }

        if (rootTile && rootTile.content == null)
        {
            rootTile.content = this;
        }
#endif
    }
}
